﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Rabbit.Domain;
using Rabbit.ErCode;
using Rabbit.Read.API.Dtos;
using Rabbit.Read.API.GetRepository.Commders;

namespace Rabbit.Read.API.Controllers
{
    /// <summary>
    /// Read-读的方法
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class ReadWtnController : ControllerBase
    {
        private readonly IMediator mediator;

        public ReadWtnController(IMediator mediator)
        {
            this.mediator = mediator;
        }

        /// <summary>
        /// 类型名称查询
        /// </summary>
        /// <param name="get"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<Merchan>>> GetMerchan()
        {
            return await mediator.Send(new GetMerchancommder());
        }

        /// <summary>
        /// 商品信息表分页
        /// </summary>
        /// <param name="show"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<APIPing<MerchanDto>>> FMerchanShow([FromQuery]ShowMerchandCommdes show)
        {
            return await mediator.Send(show);
        }

        /// <summary>
        /// 查询单个数据
        /// </summary>
        /// <param name="backfill"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<APIResult<List<MerchandiseMangem>>> GetMMangem([FromQuery]BackfillMerchandCommder backfill)
        {
            return await mediator.Send(backfill);
        }

    }
}
